//
//  MainViewController.m
//  weiboObjectC
//
//  Created by 隗杰 on 16/2/12.
//  Copyright © 2016年 kkk. All rights reserved.
//

#import "MainViewController.h"
#import "HomeTableViewController.h"
#import "MassageTableViewController.h"
#import "DiscoverTableViewController.h"
#import "ProfileTableViewController.h"
#import "mainTabBar.h"

@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    mainTabBar *mainTab = [[mainTabBar alloc] init];
    
    [mainTab.butn addTarget:self action:@selector(plusButnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self setValue:mainTab forKey:@"tabBar"];
    self.tabBar.tintColor = [UIColor orangeColor];

    [self addChildView];
    
}

- (void)plusButnClick {
    NSLog(@"sss");
}

- (void)addChildView {
    
    HomeTableViewController *home = [[HomeTableViewController alloc] init];
    
    MassageTableViewController *massage = [[MassageTableViewController alloc] init];
    
    DiscoverTableViewController *discover = [[DiscoverTableViewController alloc] init];
    
    ProfileTableViewController *profile = [[ProfileTableViewController alloc] init];
    
    [self addChildViewController: home title:@"首页" imageName:@"tabbar_home"];
    [self addChildViewController: massage title:@"消息" imageName:@"tabbar_message_center"];
    [self addChildViewController:discover title:@"发现" imageName:@"tabbar_discover"];
    [self addChildViewController:profile title:@"我" imageName:@"tabbar_profile"];
}

- (void)addChildViewController:(UITableViewController *)vc title:(NSString *)title imageName:(NSString *)imageName {

    
    UINavigationController *nav = [[UINavigationController alloc] init];
    
    vc.tabBarItem.title = title;
    vc.navigationItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:imageName];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",imageName]];
    
    [nav addChildViewController:vc];
    
    [self addChildViewController:nav];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}



@end
